package cn.zahou.SJR;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import javax.sql.DataSource;
import java.sql.*;

@SuppressWarnings("ALL")
public class MySQL_pool_select {
    public static void main(String[] args) throws SQLException {
        //    创建数据库连接池
//        DataSource ds=new ComboPooledDataSource("otherc3p0");
        DataSource ds=new ComboPooledDataSource();
//    2.获取连接对象
        Connection connection=ds.getConnection();
        PreparedStatement pstmt=null;
        ResultSet rs=null;
        String sql = "select  * from emp";
        pstmt=connection.prepareStatement(sql);
//        处理select查询操纵
        rs=pstmt.executeQuery();
        while (rs.next()){
            System.out.printf("%3s\t%.2f\n",rs.getString("name"),rs.getDouble("salary"));
        }

//        System.out.println(connection);
    }
}
